package paneles;

import interfaz.Interfaz_Peliculas;

import javax.swing.JPanel;

import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import java.awt.GridBagConstraints;
import javax.swing.JLabel;
import java.awt.Insets;
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import java.awt.Color;
import javax.swing.JList;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

import estructurasDeDatos.ArrayList2.ArrayList2;
import estructurasDeDatos.List2.List2;
import estructurasDeDatos.List2.ListIterador;

public class PanelBotones extends JPanel implements ListSelectionListener {
	private JPanel contentPane;
	private JList list;

	/**
	 * Create the panel.
	 */
	public PanelBotones() {
		setBorder(new TitledBorder(null, "Busquedas", TitledBorder.LEADING,
				TitledBorder.TOP, null, Color.DARK_GRAY));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
				0, 0, 0, 0, 0, 0 };
		gridBagLayout.columnWeights = new double[] { 1.0, 1.0, 1.0, 1.0, 1.0,
				1.0, 1.0, 1.0, Double.MIN_VALUE };
		gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
				Double.MIN_VALUE };
		setLayout(gridBagLayout);
		contentPane = new JPanel();
		list = new JList();
		list.setBounds(427, 5, 2, 252);
		//contentPane.add(list);

		String[] arr = new String[40];
		arr[0] = "1test1";
		arr[1] = "2test2";
		arr[2] = "3test3";
		arr[3] = "4test4";
		arr[4] = "5test5";
		arr[5] = "1test1";
		arr[6] = "2test2";
		arr[7] = "3test3";
		arr[8] = "4test4";
		arr[9] = "5test5";
		arr[10] = "1test1";
		arr[11] = "2test2";
		arr[12] = "3test3";
		arr[13] = "4test4";
		arr[14] = "5test5";
		arr[15] = "1test1";
		arr[16] = "2test2";
		arr[17] = "3test3";
		arr[18] = "4test4";
		arr[19] = "5test5";
		arr[20] = "1test1";
		arr[21] = "2test2";
		arr[22] = "3test3";
		arr[23] = "4test4";
		arr[24] = "5test5";
		arr[25] = "1test1";
		arr[26] = "2test2";
		arr[27] = "3test3";
		arr[28] = "4test4";
		arr[29] = "5test5";
		list.setListData(arr);
		//list.setVisibleRowCount(5);
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		list.addListSelectionListener(this);

		JScrollPane scrollPane = new JScrollPane(list);
		scrollPane.setBounds(5, 5, 112, 73);
		
		setLayout(new BorderLayout(10,10));
		
		add(scrollPane,BorderLayout.CENTER);
		add(contentPane, BorderLayout.SOUTH);
		scrollPane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		contentPane.setLayout(new GridLayout(2,2));
		GridBagConstraints gbc_scrollPane = new GridBagConstraints();
		gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
		gbc_scrollPane.gridwidth = 7;
		gbc_scrollPane.gridx = 1;
		gbc_scrollPane.gridheight = 13;
		gbc_scrollPane.gridy = 0;
		//add(scrollPane, gbc_scrollPane);
		GridBagConstraints gbc_list = new GridBagConstraints();
		gbc_list.insets = new Insets(0, 0, 5, 5);
		gbc_list.gridx = 0;
		gbc_list.gridy = 1;
		//add(list, gbc_list);

		JButton btnPorNombre = new JButton("Por nombre");
		GridBagConstraints gbc_btnPorNombre = new GridBagConstraints();
		gbc_btnPorNombre.gridwidth = 3;
		gbc_btnPorNombre.insets = new Insets(0, 0, 5, 5);
		gbc_btnPorNombre.gridx = 0;
		gbc_btnPorNombre.gridy = 13;
		contentPane.add(btnPorNombre);

		JButton btnNewButton = new JButton("Por a\u00F1o");
		GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.gridwidth = 3;
		gbc_btnNewButton.insets = new Insets(0, 0, 5, 5);
		gbc_btnNewButton.gridx = 4;
		gbc_btnNewButton.gridy = 13;
		contentPane.add(btnNewButton);

		JButton btnNewButton_1 = new JButton("Por Rango");
		GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints();
		gbc_btnNewButton_1.insets = new Insets(0, 0, 0, 5);
		gbc_btnNewButton_1.gridwidth = 3;
		gbc_btnNewButton_1.gridx = 0;
		gbc_btnNewButton_1.gridy = 15;
		contentPane.add(btnNewButton_1);

		JButton btnNewButton_2 = new JButton("Por Descripcion");
		GridBagConstraints gbc_btnNewButton_2 = new GridBagConstraints();
		gbc_btnNewButton_2.insets = new Insets(0, 0, 0, 5);
		gbc_btnNewButton_2.gridwidth = 3;
		gbc_btnNewButton_2.gridx = 4;
		gbc_btnNewButton_2.gridy = 15;
		contentPane.add(btnNewButton_2);


	}

	@Override
	public void valueChanged(ListSelectionEvent arg0) {
		// TODO Auto-generated method stub
		// Consumo consumo = (Consumo) list.getSelectedValue() ;
		// if ( consumo != null)
		// JOptionPane.showMessageDialog( parent , consumo.toString2()) ;
		//

	}

	public void acutalizar(List2 consumos) {
		// ListIterador< Consumo> it = consumos.darIterador() ;
		// ArrayList2< Consumo> aux = new ArrayList2<Consumo>() ;
		//
		// while ( it.hasNext()) {
		// aux.add( it.getNext()) ;
		// }
		// list.setListData( aux.getArray()) ;
	}

}
